package cate.common.table.res.sign.item;

import cate.common.table.ESheet;
import easy.java.dev.note.NoteClass;

import java.util.HashMap;
import java.util.Map;


@NoteClass("每日签到 奖励配置Sheet")
public class DailySignItemSheet extends ESheet<DailySignItemRow> {
    @Override
    public String getSheetName() {
        return "每日签到";
    }

    /**
     * 分组对应的最大签到天数
     */
    private Map<Integer, Integer> groupToMaxDay = new HashMap<>();

    @Override
    protected void onLoaded() {
        super.onLoaded();
        groupToMaxDay.clear();
        for (DailySignItemRow config : getList()) {
            if (groupToMaxDay.containsKey(config.group)) {
                if (config.day > groupToMaxDay.get(config.group)) {
                    groupToMaxDay.put(config.group, config.day);
                }
            } else {
                groupToMaxDay.put(config.group, config.day);
            }
        }
    }

    /**
     * 获取分组最大签到天数
     */
    public int getMaxDay(int group) {
        if (groupToMaxDay.containsKey(group)) {
            return groupToMaxDay.get(group);
        }
        return 0;
    }
}
